package com.cloudservice.ccs.biz.impl;

import com.cloudservice.ccs.biz.IGroupManageBiz;
import com.cloudservice.ccs.entity.GroupManage;
import com.cloudservice.ccs.exception.CustomerServiceException;
import com.cloudservice.ccs.exception.GroupManageException;
import com.cloudservice.ccs.mapper.GroupManageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class GroupManageImpl implements IGroupManageBiz {
    @Autowired
    private GroupManageMapper groupManageMapper;
    @Override
    public void save(GroupManage groupManage) {
        int result = groupManageMapper.save(groupManage);
        if (result == 0) {
            throw new GroupManageException("Create GroupManage entity error");
        }
    }

    @Override
    public void update(Integer id, GroupManage groupManage) {
        int result = groupManageMapper.update(id, groupManage);
        if (result == 0) {
            throw new GroupManageException("Update GroupManage entity error");
        }
    }

    @Override
    public void delete(Integer id) {
        int result = groupManageMapper.delete(id);
        if (result == 0) {
            throw new GroupManageException("Delete GroupManage entity error");
        }
    }
    @Override
    public void partialUpdate(Integer id, Map<String, Object> fields) {

        int result = groupManageMapper.partialUpdate(id, fields);
        if (result == 0) {
            throw new GroupManageException("Update GroupManage entity error");
        }

    }
    @Override
    public GroupManage getOne(Integer id) {
        GroupManage groupManage = groupManageMapper.getOne(id);
        if (groupManage == null) {
            throw new GroupManageException("Get GroupManage entity error: no such entity");
        }
        return groupManage;
    }

    @Override
    public List<GroupManage> getAll() {
        return groupManageMapper.getAll();
    }
}
